package com.kamistoat.meimeimall.meimeimallproduct.web;

import com.kamistoat.meimeimall.common.annotation.DubboAndHTTPExceptionCatch;
import com.kamistoat.meimeimall.common.utils.R;
import com.kamistoat.meimeimall.meimeimallproduct.service.SkuInfoService;
import com.kamistoat.meimeimall.meimeimallproduct.vo.thymeleaf.skuItem.SkuItemVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;

/**
 * 商品详情页
 */
@Api(tags = "商品详情页操作")
@RestController
@RequestMapping("web")
public class ProductPageController {

    @Autowired
    SkuInfoService skuInfoService;

    /**
     * 获取商品详情信息
     *
     * @param skuId skuId
     * @return R R对象，内含 skuItemVo
     */
    @ApiOperation("商品详情页获取商品详情")
    @GetMapping("/full_product_info/{skuId}")
    @DubboAndHTTPExceptionCatch
    public R getFullProductInfo(@PathVariable("skuId") Long skuId) {
        SkuItemVo skuItemVo = skuInfoService.getSkuItem(skuId);
        return R.ok().put("skuItemVo", skuItemVo);
    }
}
